package com.ysd.lis.service.lab;

import com.baomidou.mybatisplus.extension.service.IService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.ysd.common.Result;
import com.ysd.lis.entity.lab.LabCriticalReport;
import com.ysd.lis.entity.lab.LabCriticalReportDto;
import com.ysd.lis.entity.lab.LabMaininfo;
import com.ysd.lis.entity.lab.LabRptresult;
import com.ysd.lis.request.AddLabMaininfo;
import com.ysd.lis.request.DeleteResultParam;
import com.ysd.lis.request.Params;
import com.ysd.lis.request.RptResultDto;
import com.ysd.lis.request.men.ChannelInfoDto;
import com.ysd.lis.request.men.TestInfoDto;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author Bai
 * @since 2023-12-26
 */
public interface LabRptresultService extends IService<LabRptresult> {

    Result deleteRptResults(DeleteResultParam deleteResultParam);

    Result insertRptResult(LabRptresult labRptresult) throws JsonProcessingException;

    Result updateRptResult(LabRptresult labRptresult) throws JsonProcessingException;

    Result updateRepetition(LabRptresult labRptresult) ;

    Result findRptResultItem(Params params);

    Result findRptResultItemAll(Params params);

    Result findReviewedResutBySampleNo(String sampleNo);

    Result batchAddResultItemList(RptResultDto dto);

    Result getSpecResult(String reqNo,String sampleNo);

    /**
     * 重新计算检验结果
     */
    Result reCalcRptRssults(LabMaininfo mainInfo);

    /**
     * 批量重新计算检验结果
     */
    boolean reCalcRptRssultsMany(List<LabMaininfo> mainInfos);

    Result getAlarmResultByMainId(LabCriticalReportDto criticalReportDto);

    /**
     * 查询未处理的危急值
     *
     * @param mainInfoIds 检验主记录Id集合
     */
    List<LabRptresult> getAlarmResultByMainIds(List<String> mainInfoIds);

    /**
     * 查询是否有未处理的危急值
     *
     * @param ids 检验记录主键集合
     */
    Result getAlarmExistsByMainInfoIds(List<String> ids);

    /**
     * 获取标本列表
     * @param testInfoDto
     */
    Result getSampleListAsync(TestInfoDto testInfoDto);

    /**
     * 确认标本执行
     * @param testInfoDto
     */
    Map<String, Object> completeSampleAsync(TestInfoDto testInfoDto);

    /**
     * 获取双向通道号、标本号等获取双向通道号、标本号等
     * @param channelInfoDto
     */
    Result getChannelInfoAsync(ChannelInfoDto channelInfoDto);
    /*文字结果处理*/
    void CalcTextResult(LabMaininfo labMaininfo,List<LabRptresult> rptResultList);

    /*结果二次处理*/
    void  CalcTransResult(LabMaininfo labMaininfo,List<LabRptresult> rptResultList);

    //计算项目处理
    Result  CalcFormulaItemResult(LabMaininfo labMaininfo,List<LabRptresult> rptResultList);

    /*计算参考范围，结果标志*/
    void  CalcItemDictRefers(LabMaininfo labMaininfo,List<LabRptresult> rptResultList);

    /*计算危急值*/
    void   CalcItemDictCritical(LabMaininfo labMaininfo,List<LabRptresult> rptResultList);

     void CalcItemDictSpecialRules(LabMaininfo mainInfo,List<LabRptresult> rptresultlist);

    Result findRptResultItemByTemp(Params params);

    Result upDataRptResultByTempId(Params params);

    Result findLabTemplateDetailByTempId(String templateId);

    Result saveImgTxtRptValue(LabRptresult labRptresult) throws JsonProcessingException;

    Result addMaininfoByReqNo(AddLabMaininfo labReqMain) throws JsonProcessingException;

    Result addMaininfo(String rptGroup, String sampleda, String sampleNo) throws JsonProcessingException;

    Result findRptResultItemByTempId(Params params);

    Result saveImgTxtRptValueBatch(List<LabRptresult> labRptresults) throws JsonProcessingException;

    Result updateResult(LabMaininfo labMaininfo);

    Result removeLabRptResultList(RptResultDto resultDto);
}
